/*
 * @Description:
 * @Author: maskMan
 * @LastEditTime: 2024-03-29 19:18:18
 */
import { _decorator, Component, Node, __private, NodeEventType, EventTouch, Camera, SkeletalAnimation } from 'cc'
import QuickManager from '../general/quickManager'
import util from '../general/util'
const { ccclass, property } = _decorator

@ccclass('roleAction')
export class headBoard extends Component {
  @property(Node)
  roleNode: Node = null
  @property(SkeletalAnimation)
  roleAnima: SkeletalAnimation = null
  @property(Camera)
  camera: Camera = null
  animaList: string[] = ['Balance', 'Downback', 'Downfront', 'Jumpfall', 'Melee03']
  isAction = false
  start() {
    QuickManager.instance = new QuickManager()
    this.node.on(NodeEventType.TOUCH_START, (e: EventTouch) => {
      if (this.isAction == true) {
        return
      }
      const ret = QuickManager.instance.isTouchGameModel(e, this.roleNode, this.camera)
      if (ret) {
        this.isAction = true
        const animaName = this.animaList[util.getRandomInt(0, this.animaList.length - 1)]
        console.log(animaName)
        QuickManager.instance.playSkelAnimation(this.roleAnima.node, animaName).then(() => {
          this.isAction = false
          QuickManager.instance.playSkelAnimation(this.roleAnima.node, 'Idle3rdP01')
        })
      }
    })
  }
  update(deltaTime: number) {}
}
